﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace BLL.Sec
{
    /// <summary>
    /// 业务逻辑类OperateLog 的摘要说明。
    /// </summary>
    public class OperateLog
    {
        private readonly OracleDAL.Sec.OperateLog dal = new OracleDAL.Sec.OperateLog();
        public OperateLog()
        { }
        #region  成员方法
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(string LOGISN)
        {
            return dal.Exists(LOGISN);
        }

        /// <summary>
        /// 增加一条数据 ,LOGISN字段已经自动生成，不用赋值
        /// </summary>
        public void Add(Model.Sec.OperateLog model)
        {
            dal.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Model.Sec.OperateLog model)
        {
            dal.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public void Delete(string LOGISN)
        {

            dal.Delete(LOGISN);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.Sec.OperateLog GetModel(string LOGISN)
        {

            return dal.GetModel(LOGISN);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Model.Sec.OperateLog> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            List<Model.Sec.OperateLog> modelList = new List<Model.Sec.OperateLog>();
            int rowsCount = ds.Tables[0].Rows.Count;
            if (rowsCount > 0)
            {
                Model.Sec.OperateLog model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Model.Sec.OperateLog();
                    model.LOGISN = ds.Tables[0].Rows[n]["LOGISN"].ToString();
                    model.OPERATERESULT = ds.Tables[0].Rows[n]["OPERATERESULT"].ToString();
                    model.OPERATEID = ds.Tables[0].Rows[n]["OPERATEID"].ToString();
                    model.BELONGSYSTEM = ds.Tables[0].Rows[n]["BELONGSYSTEM"].ToString();
                    model.USERISN = ds.Tables[0].Rows[n]["USERISN"].ToString();
                    model.USERNAME = ds.Tables[0].Rows[n]["USERNAME"].ToString();
                    if (ds.Tables[0].Rows[n]["OPERATIONTIME"].ToString() != "")
                    {
                        model.OPERATIONTIME = DateTime.Parse(ds.Tables[0].Rows[n]["OPERATIONTIME"].ToString());
                    }
                    model.IPADDR = ds.Tables[0].Rows[n]["IPADDR"].ToString();
                    model.MACADDR = ds.Tables[0].Rows[n]["MACADDR"].ToString();
                    model.OPERATENAME = ds.Tables[0].Rows[n]["OPERATENAME"].ToString();
                    model.OPERATERESOURCE = ds.Tables[0].Rows[n]["OPERATERESOURCE"].ToString();
                    model.OPERATECONTENT = ds.Tables[0].Rows[n]["OPERATECONTENT"].ToString();
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        //public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        //{
        //return dal.GetList(PageSize,PageIndex,strWhere);
        //}

        #endregion  成员方法
    }
}
